<%@page import="java.net.URLDecoder"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8" import="java.sql.*" import="java.util.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>获得学校</title>
</head>
<body>
<%
request.setCharacterEncoding("utf-8");
Connection con=null;
String strCon;
Statement sqlStmt=null;

ResultSet sqlRst=null;

PreparedStatement stat=null;

String reg_id = URLDecoder.decode(request.getParameter("ID"),"utf-8");
System.out.println("reg_id = "+reg_id);
try{
	Class.forName("org.gjt.mm.mysql.Driver").newInstance();
    con=java.sql.DriverManager.getConnection("jdbc:mysql://localhost/school1130","root","root");
    sqlStmt=con.createStatement();
    //执行SQL语句
    String sqlQuery="SELECT school_num,`name` FROM school WHERE `name` LIKE '%"+reg_id+"%'";
    sqlRst=sqlStmt.executeQuery(sqlQuery);
	boolean flag = false;
	String str12 = "";
    while(sqlRst.next()){
    	flag = true;
    	str12+="<a href=which-uni.jsp?num="+sqlRst.getString(1)+"&iPage=1><font color='#ffffff'>"+sqlRst.getString(2)+"</font></a><br/>";
    }
    if(!flag)
    {
    	out.print("没有你要的学校!");
    }
    else
    {
       out.print(str12);
    }
}catch(java.sql.SQLException e){
	out.println(e.toString());
}finally{
	//关闭结果集对象
	if(sqlRst!=null)try{sqlRst.close();}catch(java.sql.SQLException e1){
		out.println(e1.toString());
	}finally{
		try{
			//关闭语句对象 
			if(sqlStmt!=null)sqlStmt.close();
	       }catch(java.sql.SQLException e2){
	    	   out.println(e2.toString());
	       }finally{
	    	   try{
	    		   //关闭数据库连接
	    		   if(con!=null)con.close();
	    	   }catch(java.sql.SQLException e3){
	    		   out.println(e3.toString());
	    	   }
	       }
	}   
}
%>
</body>
</html>